package homework4.com.zut.aop_proxy;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class TransactionManager implements MethodInterceptor {

	public void beginTransaction() {
		System.out.println("");
	}
	
	public void commit() {
		System.out.println("ύ");
	}
	
	public void rollback() {
		System.out.println("ع");
	}
	
	public void release() {
		System.out.println("ͷԴ");
	}
	
	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		Object obj = null;
		try {
			beginTransaction();
			obj = invocation.proceed();
			commit();
		} catch(Exception e) {
			rollback();
		} finally {
			release();
		}
		return obj;
	}

}